package com.sinosoft.dsp.component.bpm.viewbean.activity.part;

import org.jbpm.xsdobject.Process;

import com.sinosoft.dsp.component.bpm.service.core.BpmSelectItemsService;
import com.sinosoft.dsp.component.bpm.util.ProcessParse;
import com.sinosoft.dsp.component.bpm.viewbean.BpmJpdlDefineViewBean;
import com.sinosoft.dsp.component.bpm.viewbean.activity.IBpmActivityPartEditViewBean;
import com.sinosoft.dsp.system.core.exception.SinoException;
import com.sinosoft.dsp.system.to.IGenericTO;
import com.sinosoft.dsp.system.to.attribute.Attribute;
import com.sinosoft.dsp.system.to.helper.ToHelper;
import com.sinosoft.dsp.system.utils.Const;

public class BpmActivityJoinBaseViewBean extends BpmActivityCommonBaseViewBean
		implements IBpmActivityPartEditViewBean {
	// 流入转移数(INT)
	public static final String FIELD_MULTIPLICITY = "multiplicity";

	// 锁定模式
	public static final String FIELD_LOCKMODE = "lockmode";

	@Override
	public void init(IGenericTO tos) throws SinoException {
		super.init(tos);

		// 活动对象
		Attribute<?> name = ToHelper.getContentAttriubteByName(tos,
				BPM_NODE_NAME);
		String nameStr = name.convertToString();

		BpmJpdlDefineViewBean pvb = (BpmJpdlDefineViewBean) this.getParent()
				.getParent();
		org.jbpm.xsdobject.Process process = pvb.getProcess();
		Process.Join obj = (Process.Join) ProcessParse.getActivity(process,
				nameStr);

		this.addField(FIELD_LOCKMODE, Const.NVL(obj.getLockmode(),
				BpmSelectItemsService.SELECT_ITEM_LOCKMODE_DEFAULT));

		if (obj.getMultiplicity() != null)
			this.addField(FIELD_MULTIPLICITY, obj.getMultiplicity());
		else
			this.addField(FIELD_MULTIPLICITY, Integer.valueOf(0));
	}
}
